var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/configComponent/form/viewItem.tsx
var viewItem_exports = {};
__export(viewItem_exports, {
  default: () => viewItem_default
});
module.exports = __toCommonJS(viewItem_exports);
var import_util = require("../../util");
var import_common = require("../common");
var TextItem = (0, import_common.getComp)({ xtype: "Text" }).instance;
function viewItem_default(props) {
  var _a;
  const { "data-item": item, ...others } = props;
  const { src, value } = props;
  let val = value;
  let Comp = TextItem;
  if (src && item.xtype === "Image" || item.xtype === "Button") {
    Comp = (0, import_common.getComp)(item).instance;
  } else if (item.xtype === "RangePicker") {
    val = Array.isArray(value) ? value.join("-") : value;
  } else if (Array.isArray(item.data || item.options)) {
    const dataList = item.data || item.options;
    if (Array.isArray(value)) {
      const sets = new Set(value);
      val = (item.data || item.options).filter((item2) => sets.has(item2.value)).map((item2) => item2.label).join(",");
    } else {
      val = (_a = dataList.find((item2) => item2.value === value)) == null ? void 0 : _a.label;
    }
  } else if (Array.isArray(value)) {
    val = value.map((item2) => item2 == null ? void 0 : item2.label).join(",");
  } else {
    val = (val == null ? void 0 : val.label) || (val == null ? void 0 : val.toString());
  }
  if (import_util.iup.isNullOrEmpty(val)) {
    return null;
  }
  return /* @__PURE__ */ React.createElement(Comp, { ...others, value: val });
}
